package org.rency.common.utils.enums;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

/**
 * 编码格式
 * @author: user_rcy@163.com
 * </br>Created on
 * @version: V1.0.0
 * @since JDK 1.8
 */
public enum CharsetEnum {
    UTF8("UTF8"),
    UTF_8("UTF-8"),
    GBK("GBK"),
    ;

    private String code;

    CharsetEnum(String code){
        this.code = code;
    }

    public static CharsetEnum get(String code){
        CharsetEnum[] chars = CharsetEnum.values();
        for(CharsetEnum c : chars){
            if(c.equals(code.toUpperCase())){
                return c;
            }
        }
        return null;
    }

    public String getCode(){
    	return this.code;
    }
    
    public String toString(){
        return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
    }
}
